home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 May / PCPlus May 1998=disk A.iso / trial / gdldb / disk1 / data1.cab / Example_Files / calculator.scp < prev    next >
Encoding:
Text File  |  1998-01-21  |  1.3 KB  |  65 lines

  1. ##########################################################
  2. # GDIdB demo script (c) 1997 Global Data Industries
  3. #
  4. # This script works as a simple calculator program- no
  5. # HTML is generated.
  6. ##########################################################
  7.  
  8.  
  9.  
  10.  
  11.  
  12. ##########################################################
  13. # declare variables used in script
  14.  
  15. &defvar(?var1?,?var2?,?var3?)
  16.  
  17.  
  18.  
  19.  
  20.  
  21. ##########################################################
  22. # Print the information screen
  23.  
  24. &cls
  25. &print("Calculator Demo Script")
  26. &print("---------------------------------")
  27. &print("Press cancel or enter \"quit\" to terminate script.")
  28.  
  29.  
  30.  
  31.  
  32.  
  33. ##########################################################
  34. # the following  loop will be evaluated until the user
  35. # presses cancel (or enters quit)
  36.  
  37. &while(1)
  38. {
  39.     # ?var1? will contain "quit" unless the user
  40.     # actually enters a value
  41.     &assign(?var1?,"quit")
  42.  
  43.     # get expression from user
  44.     &input(?var1?,"Enter Arithmetic expression")
  45.  
  46.     # check that ?var1? does not equal "quit"
  47.     &strcmp(?var2?,"?var1?",ne,"quit")
  48.     &if(?var2?)
  49.     {
  50.         # calculate string as arithmetic expression using the
  51.         # assign function
  52.         &assign(?var3?,?var1?)
  53.  
  54.         # and print the results
  55.         &print("?var1?=?var3?")
  56.     }
  57.  
  58.     # if ?var1? equals "quit", jump out of the loop
  59.     &else
  60.     {    
  61.         &break
  62.     }
  63. }
  64.  
  65.